Today, then we are going to have a look at teleport service.
So what?
Teleport service is and how we can use it in our games.
So teleport service allows you to teleport players between different places in a game.
Now you might get confused when I say places.
When I say places, I don't mean from over here.
Over here you can just use the colon move to function for that one.
Nice and easy.
By different places I mean different places in your game.
So games have different places.
So um, in one game you can have multiple maps which all look different.
Those maps, the technical name for those are places.
So, um, if you want to be able to teleport these players from place to place, um, you need to use
teleport service.
Now, if you're a bit confused about places, um, you might know the game Minecraft.
Um, when I learned this, um.
It was a good a good way to understand this.
Um, but basically it's one game, but there's different dimensions.
I'm not too familiar, but there's there's different dimensions in the game.
Um, so you're not so.
So when you go from one dimension to another dimension, um, that's that's a teleport service does
basically.
So you're going from one place to another place, but still within the same game.
That's what's going on here.
So um, before we start scripting this, we will, um, well, we'll need to fetch.
Fetch some things.
So not fetch set to set some things up.
So we go over to view and go up to the asset manager.
Um, we will need to create a new place.
So we've only got one place here.
Um.
But we want to add in a second place.
So this is my first place here and this is my second one.
Let's give these names.
So if even if we rename this to be called start place.
And this one.
Um.
And place.
We want to teleport the player from a start place to the end place.
So the start place is just listed here and the end place by double click that.
So I've opened it up here.
It just loaded.
So it showed.
It showed on my desktop and stuff.
So I've skipped past that bit, but it basically loaded the end place here.
And this has a complete different explorer.
So objects you have in your starting place will not necessarily be in your ending place.
So we're going to go back and forth between these two.
But I'm going to show you how to teleport the player from one place to another place.
So let's go back to the start place and have a go at that.
So we'll need to first get the ID of the end place.
So let's copy it and get and click select um Copy to Clipboard.
We now got the ID cool.
And let's then go ahead I'm going to do this by um we need an event or something in order to trigger
this.
I'm going to add a part in and add in a proximity prompt so the player can press the key, which will
then teleport them away.
So let's add a script into here.
So local proximity.
Prompt.
We can close this now.
We don't need it is equal to script dot parent dot proximity.
Prompt proximity.
Prompt dot activated.
So it was dot dot triggered.
Kinect function player.
Okay, let's get teleport service.
So, um.
Local teleport service is equal to.
Game on.
Get service.
Teleport service.
Um, we've got we've got our proximity point.
Let's also create a variable for the place ID so local place id is equal to this one there.
Okay, so on this proximity prompt when it's once it's occurred.
Um.
Or the player here as well.
We want to teleport the player, and to do this we use the teleport function.
So teleport service colon teleport.
And then here we have a couple bits of information to pass over.
We want to pass a place ID which is just up here.
We want to pass over the player which is listed just here as a parameter and any teleport data.
Now when you're going from place to place, you might want to pass over some data.
Now this can be anything such as things like a number of coins.
They have, um, stuff that you want to be passed over.
Because remember, any script you write in this place will not necessarily be there any other place.
It can also be really simple things such as, um, is the player crouching or in prone?
Because if they're went over, if they went to this other dimension or this other place in their game,
crouching or in prone, it will make it will make the transition a bit more seamless if they're also
crouching or in prone when they reach the other area, basically.
Okay, um, for now, I'm not going to use any anything.
There's not really anything I can have to pass over, but anything will go over there, basically.
Okay.
So that's it for this has this area over here.
Now remember this will be in two sections.
We'll have 111 script here which will teleport.
Teleport them and we'll have another script which if you are using, if you are using some teleport
data which I will show you how to do, I mean, if you're not wanting to use, um, any teleport data,
this will be completely fine.
This will be everything you need in order to do this, but there will be a bit a little bit of an extra
script in case you are wanting to pass over any kind of teleport data.
So let's give this a try out.
So let's play the game.
And, um.
Let's go over.
And see if this works.
And it comes with an error.
Teleport failed due to an unexpected error and the output it says syllable failed event.
Teleport failed because cannot teleport in the studio, so unfortunately this is great.
However, we can't try this in Roblox studio.
It can only be tried in the game so you will have to save, save your game, publish your game and try
out actually in a game in order for this to work, unfortunately.
Um, so it's a bit annoying that I can't show you this properly, properly working, but I've tested
this code and no 100% that it works.
Now, just to show you what you might want to write, um, in your other place.
So if you add a script in here just to show you.
So you basically want to fetch teleport service again.
So teleport service is equal to game get service.
Teleport service.
Um and get the player through a local script.
Sorry.
Um, this is going to be done locally because the, um, information is going to be, um, can I close
the database now?
Thank you.
So yeah, because the information is going to be passed, um, per player.
So yeah.
Shumpert local script in the workspace.
I'm just doing it to quickly show you, um, so local teleport.
Service is equal to game.
Get service.
Teleport service.
Local player is equal to game.
Dot players.
Local player and watch one line.
Teleport data.
So local teleport data.
Is equal to teleport service.
Colon gets local player teleport data.
This will basically create a table with any data that you passed over.
So things like how many coins have they got?
How much experience have they got?
Are they crouching?
Are they in prone?
Are they doing anything else.
Although we have do we have a something equipped.
But you should sure have crypt in the other dimension as well.
Um, all that kind of stuff.
You can set it up and make sure that the transferring between those two places is very seamless using
that teleport data.
Just there.
And there you go.
So I can't show you this working.
But I promise you, if you take a look and try out the game, actually playing it in Roblox, it will
work.
So I actually encourage you to do this, publish it and just give it a try to see the effect.
So basically it will look like um, just like this here.
So when you play the game you have a loading screen like this.
Then you when you fall down into the game or you spawn at the spawn location exactly like that, but
when you click a button, basically is what it does.
And, um, there you go.
That is teleport service.
Um, now I will be adding, um, and that's also the, um, last lecture in this section.
Now, um, I will be adding some other, some other lectures in this section and other sections really,
but especially this section is where I want to add quite a lot, quite a lot more to, um, over the
coming months and even years.
Um, so this won't be the last one I'll ever record, but, um, it will be the last in order when you
watch them.
So if you have gone through these four sections, um, in order, I mean, well done.
Um, I've recorded a lot here and, um, you if you have followed along through this, um, you pretty
much know everything Roblox has to offer.
I mean, um.
Any kind of any basically any kind of hit game, any anything you can access it, you can make it.
Obviously in the next section, we're going to look a bit more of the application of some of these more
advanced areas.
We're going to have a look at making a simulator style game.
So if you are interested in applying all this knowledge, which I think is very important, especially
the more advanced advanced topics, do have a look and at the games.
But yeah.
So hope you've enjoyed this section.
You know, either you're watching this in the correct order or you're just jumping area to area.
Everyone's completely fine.
But um, you know, this would be the last one in this section.
So hopefully you've enjoyed looking at this more advanced scripting.
I've really enjoyed teaching it.
I think some of these topics are really cool and there's not much difficult.
People think advanced scripting is like lighting, writing hundreds of lines of code.
It's really not.
I hope you kind of realize that advanced scripting doesn't really sound too bad.
Obviously it's good saying that once you when you once you understand the know it all.
But, um, there's not a whole lot of code involved in a lot of these things.
It's usually a lot of it has handled by robots themselves.
And you're just doing the basic stuff like firing things.
It's basically with events, with services and stuff.
It's basically just firing, um, functions, receiving events, that kind of stuff.
But, um, yeah, hopefully you've enjoyed this.
Um, and hopefully I will see you in whatever area of the course you go on to next.